Skip to content

Implement all improvements.md runtime/config refactors in packaged mod source - #3

Draft
codebooo with Copilot wants to merge 2 commits into
copilot/analyze-uch-knockback-modfrom
copilot/improve-documentation-and-code
Draft

Implement all improvements.md runtime/config refactors in packaged mod source#3
codebooo with Copilot wants to merge 2 commits into
copilot/analyze-uch-knockback-modfrom
copilot/improve-documentation-and-code

Conversation

Copilot AI commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

This PR applies the full set of improvements documented in improvements.md to the mod implementation shipped in Knockback_Mod_v1.0.0.zip. The update focuses on safer config handling, lower per-activation overhead, cleaner physics timing, and clearer plugin metadata/runtime behavior.

  • Config + metadata hardening

    • Added bounded config entries for knockback force/radius via AcceptableValueRange<float>.
    • Introduced plugin constants (PluginGuid, PluginName, PluginVersion) and updated version usage to 1.0.1.
    • Added DebugLogging config to gate high-frequency per-target logs.
  • Runtime performance refactor

    • Replaced full-scene FindObjectsOfType<GameObject>() scans with non-alloc physics overlap queries (Physics2D.OverlapCircleNonAlloc, Physics.OverlapSphereNonAlloc).
    • Added lazy local-player caching with scene-change invalidation/refresh.
    • Removed string-allocation heuristics (ToLower) in favor of IndexOf(..., StringComparison.OrdinalIgnoreCase).
  • Physics correctness + safety

    • Moved trigger execution from Update to FixedUpdate through a pending-action queue.
    • Removed transform-position fallback for objects without rigidbodies (skip non-physics targets).
    • Computed 2D knockback direction explicitly on planar axes before impulse application.
  • Harmony behavior cleanup

    • Removed implicit Harmony PatchAll() initialization because no explicit patch classes exist in the plugin source.
  • Packaged docs/metadata alignment

    • Updated packaged manifest/changelog/readme (inside zip) and root README.md to reflect new behavior/settings and version alignment.
KnockbackForce = Config.Bind(
    "Knockback", "Force", 15f,
    new ConfigDescription("Force of the knockback (higher = stronger push)",
        new AcceptableValueRange<float>(0f, 100f)));

private void Update()
{
    if (EnableMod.Value && Input.GetKeyDown(KnockbackKey.Value))
        _pendingKnockback = true;
}

private void FixedUpdate()
{
    if (!EnableMod.Value || !_pendingKnockback) return;
    _pendingKnockback = false;
    ApplyKnockbackFromLocalPlayer();
}

Copilot AI changed the title [WIP] Update improvements as stated in improvements.md Implement all improvements.md runtime/config refactors in packaged mod source Apr 6, 2026
Copilot AI requested a review from codebooo April 6, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants